class PObj
  attr_accessor :attributes,:commands,:functions,:oname,:cfg,:dbref
  def initialize(cfg=nil,dbref=nil,oname=nil,atty=nil,cmd=nil,fun=nil)
    if atty==nil
      @attributes = {:and=>{},:at=>{}}
    end
    if cmd==nil
      @commands = {}
    end
    if fun ==nil
      @functions = {}
    end 
    @oname = oname
    @cfg = "data/#{@oname}_object.ocfg"
    @dbref=dbref
  end
  def add_fun(name,body)
    @functions[name]=body
  end
  def add_cmd(name,body)
    @functions[name]=body
  end
  def add_atty(name,body)
    @functions[name]=body
  end
  def write
    File.open("data/#{@oname}_pobject.ocfg","w") {|f|
      f.puts "#{self.to_yaml}"
    }
  end
end


class Project
  attr_accessor :server_data,:pname,:objects,:cfg
  def initialize(server_data=nil,pname=nil,objects=[])
    @pname,@objects = pname,objects
    @cfg = "data/#{@pname}_project.pcfg"
    if server_data!=nil
      @server_data=server_data
    else
      @server_data = ServerData::new("data/default_server.scfg")
    end
  end
  def add_object obj
    @objects << obj.cfg
    write()
  end
  
  def write
    File.open("data/#{@pname}_project.pcfg","w") {|f|
      f.puts "#{self.to_yaml}"
    }
  end
end